<template>
  <div class="site-wraps">
    <div class="site-swiper">
      <van-swipe class="my-swipe" :autoplay="3000" indicator-color="white">
        <van-swipe-item v-for="(item, index) in bannerArr" :key="index">
          <img :src="item" alt="" />
        </van-swipe-item>
      </van-swipe>
    </div>
    <div class="total">
      <div>今日管内人数</div>
      <div class="loading">
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
        <span></span>
      </div>
      <div class="num">{{ siteInfo.capacity }}</div>
    </div>

    <!-- 场馆介绍 -->
    <div class="city-info">
      <div class="info-top">
        <div class="city-title">
          <img
            src="https://ya30images.hbwlife.com/wxmp/logo-yongan30.png"
            mode=""
          />
          <div class="txt">泳安30</div>
        </div>
        <div class="tag-wrap">
          <div class="card-box">
            <div class="every">体育游泳馆</div>
            <div class="every">休闲娱乐</div>
            <div class="every">深水区</div>
            <div class="every">浅水区</div>
          </div>
        </div>
        <!-- <div class="site-toggle">
          <img class="toggle-btn" src="@/static/img/toggle.png" />
          <div class="txt">切换场馆</div>
        </div> -->
      </div>
      <div class="info-bottom">
        <div class="address">北京金泳安科技有限公司</div>
        <div class="right">
          <img
            class="nav"
            @click="goToLocation"
            src="./../../assets/img/nav.png"
          />
          <div class="line"></div>
          <img
            class="phone"
            @click="callPhoneNumber()"
            src="./../../assets/img/phone.png"
          />
        </div>
      </div>
    </div>
    <!--  -->
    <div class="yellow">团购购票</div>

    <div class="hot-wrap">
      <div class="title-wrap">
        <div class="title-line"></div>
        <div class="title">热门活动</div>
      </div>

      <div class="item-wrap">
        <div class="item">
          <div class="txt1">最新活动</div>
          <div class="txt2">查看</div>
        </div>
        <div class="item">
          <div class="txt1">热门场馆</div>
          <div class="txt2">查看</div>
        </div>
        <div class="item">
          <div class="txt1">卡课推荐</div>
          <div class="txt2">查看</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { onMounted, reactive, toRefs, ref, watch } from 'vue'
import { postData } from '@/request/request.js'
import { useRoute, useRouter } from 'vue-router'
let router = useRouter()
let route = useRoute()
let query = route.query
localStorage.clear()
localStorage.setItem('open_id', query.open_id)
localStorage.setItem('user_id', query.user_id)
localStorage.setItem('access_token', query.access_token)
localStorage.setItem('currentPath', query.currentPath)

let bannerArr = ref([])
let siteInfo = ref('')

let initSiteInfo = () => {
  postData('/common/site/info', { site_code: '17001', with_images: 1 })
    .then((res) => {
      siteInfo.value = res.datas
      let bannerPic = res.datas.images
      bannerArr.value.push(
        bannerPic.logo1,
        bannerPic.logo2,
        bannerPic.logo3,
        bannerPic.logo4,
        bannerPic.logo5,
        bannerPic.logo6,
        bannerPic.logo7,
        bannerPic.logo8,
        bannerPic.logo9
      )
    })
    .catch((err) => {
      console.log(err)
    })
}

let goToLocation = () => {
  wx &&
    wx.miniProgram.navigateTo({
      url: '/pages/home/location',
    })
}

let callPhoneNumber = () => {
  wx &&
    wx.miniProgram.navigateTo({
      url: '/pages/home/callPhone',
    })
}

onMounted(() => {
  initSiteInfo()
})

watch(
  () => route.fullPath,
  () => {
    initSiteInfo()
  }
)
</script>

<style scoped>
.site-wraps {
  width: 100%;
  height: 100vh;
  overflow-x: hidden;
  overflow-y: auto;
  box-sizing: border-box;
  background: #222c41;
  padding-top: 0;
  margin-top: 0;
  font-size: 0.16rem;
}

.site-swiper {
  width: 100%;
  height: 1.3rem;
  padding-top: 0;
  margin: 0 auto;
}
.site-swiper .my-swipe {
  width: 100%;
  height: 100%;
}
.my-swipe .van-swipe-item {
  color: #fff;
  font-size: 0.12rem;
  line-height: 2rem;
  text-align: center;
  background-color: #39a9ed;
}
.van-swipe-item img {
  width: 100%;
  height: 100%;
}

.total {
  color: #eec07e;
  height: 0.3rem;
  line-height: 0.3rem;
  margin-top: 0.1rem;
  padding: 0 0.1rem;
  font-size: 0.14rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

/* info */
.city-info {
  width: 96%;
  height: auto;
  margin: 0 auto;
  margin-top: 0.1rem;
  padding: 0 0.1rem;
  box-sizing: border-box;
}

.city-info .info-top {
  display: flex;
  justify-content: center;
  flex-flow: column;
  align-items: flex-start;
  height: 0.8rem;
  line-height: 1;
  background: #283145;
  border-radius: 0.1rem 0.1rem 0 0;
}

.city-title {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 0 0.1rem;
}

.city-title img {
  width: 0.4rem;
  height: 0.4rem;
  margin-right: 0.08rem;
}

.city-title .txt {
  color: #fff;
}

.city-info .info-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 0.5rem;
  background: #2c3448;
  padding: 0 0.1rem;
  box-sizing: border-box;
  border-radius: 0 0 0.1rem 0.1rem;
}

.info-bottom .address {
  font-size: 0.14rem;
  color: #fff;
}

.info-bottom .right {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.info-bottom .right .nav {
  width: 0.2rem;
  height: 0.2rem;
}
.line {
  width: 0.01rem;
  height: 0.16rem;
  color: #f6c782;
  margin: 0 0.1rem;
  background: #f6c782;
}
.info-bottom .right .phone {
  width: 0.2rem;
  height: 0.2rem;
}

/*  */
.tag-wrap {
  box-sizing: border-box;
  padding: 0.1rem;
  font-size: 0.14rem;
}

.card-box {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.every {
  background: #80a1e0;
  margin-right: 0.1rem;
  padding: 0.04rem;
  border-radius: 0.05rem;
  font-size: 0.12rem;
  color: #09388a;
}

/*  */
.yellow {
  
  width: 94%;
  height: 0.4rem;
  margin: 0 auto;
  margin-top: 0.15rem;
  border-radius: 0.08rem;
  line-height: 0.4rem;
  color: #533504;
  background: linear-gradient(to right, #c8a357, #fbde94, #c8a357);
  display: flex;
  justify-content: center;
  align-items: center;
}

.hot-wrap {
  width: 94%;
  height: auto;
  margin: 0 auto;
  margin-top: 0.2rem;
  background: #293247;
  padding: 0.1rem;
  box-sizing: border-box;
  border-radius: 0.1rem;
  padding-bottom: 0.25rem;
}

.hot-wrap .title-wrap {
  display: flex;
  justify-content: flex-start;
  align-items: center;
}

.hot-wrap .title {
  width: 100%;
  height: 0.4rem;
  line-height: 0.4rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  box-sizing: border-box;
  color: #fff;
}

.hot-wrap .title-line {
  width: 0.03rem;
  height: 0.15rem;
  background-color: #fff;
  border-radius: 0.02rem;
  box-sizing: border-box;
  margin-right: 0.1rem;
}

.hot-wrap .item-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: 1.3rem;
  margin: 0 auto;
  margin-top: 0.1rem;
}

.hot-wrap .item {
  width: 32%;
  height: 100%;
  border-radius: 0.1rem;
  display: flex;
  flex-flow: column;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.2);
}

.hot-wrap .item .txt1 {
  color: #fff;
  font-size: 0.14rem;
}

.hot-wrap .item .txt2 {
  color: #d5ad57;
  font-size: 0.12rem;
  margin-top: 0.1rem;
}
/* loading */
@keyframes load {
  0%,
  100% {
    height: 0.04rem;
    background: #7ddb26;
  }

  50% {
    height: 0.12rem;
    margin: -0.04rem 0;
    background: #0088ff;
  }
}
.loading {
  width: auto;
  height: 100%;
  margin: 0 0.06rem;
}
.loading span {
  display: inline-block;
  width: 0.03rem;
  height: 0.04rem;
  margin: 0 0.03rem;
  border-radius: 0.04rem;
  background: #80a1e0;
  animation: load 5s ease infinite;
}

.loading span:nth-child(2) {
  animation-delay: 0.5s;
}
.loading span:nth-child(3) {
  animation-delay: 1s;
}
.loading span:nth-child(4) {
  animation-delay: 1.5s;
}
.loading span:nth-child(5) {
  animation-delay: 2s;
}
.loading span:nth-child(6) {
  animation-delay: 2.5s;
}
.loading span:nth-child(7) {
  animation-delay: 3s;
}
.loading span:nth-child(8) {
  animation-delay: 1.4s;
}
/* .loading span:nth-child(9) {
  animation-delay: 1.6s;
}
.loading span:nth-child(10) {
  animation-delay: 1.8s;
} */
/* end loading */
</style>
